home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ape-ad1a / cdxvbmus.cls < prev    next >
Text File  |  1998-10-09  |  2KB  |  70 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CDXVBMusic"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. ' WORKING!
  11.  
  12. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
  13.  
  14. Public m_HWND As Long
  15.  
  16. Public Sub Init(hWnd As Long)
  17.       m_HWND = hWnd
  18. End Sub
  19.  
  20. Public Function Play(Filename As String) As Boolean
  21.       If Filename = "" Then Play = False
  22.       Dim Buffer As String
  23.       
  24.       Buffer = "open " & Filename & " type sequencer alias MUSIC"
  25.       
  26.       If mciSendString("close all", "", 0, 0) <> 0 Then
  27.             Play = False
  28.             Exit Function
  29.       End If
  30.       
  31.       If mciSendString(Buffer, "", 0, 0) <> 0 Then
  32.             Play = False
  33.             Exit Function
  34.       End If
  35.       
  36.       If mciSendString("play MUSIC from 0 notify", "", 0, m_HWND) <> 0 Then
  37.             Play = False
  38.             Exit Function
  39.       End If
  40.       
  41.       Play = True
  42. End Function
  43.  
  44. Public Function StopPlaying() As Boolean
  45.       If mciSendString("close all", "", 0, 0) <> 0 Then
  46.             StopPlaying = False
  47.             Exit Function
  48.       End If
  49.       
  50.       StopPlaying = True
  51. End Function
  52.  
  53. Public Function Pause() As Boolean
  54.       If mciSendString("stop MUSIC", "", 0, 0) <> 0 Then
  55.             Pause = False
  56.             Exit Function
  57.       End If
  58.       
  59.       Pause = True
  60. End Function
  61.  
  62. Public Function Restart() As Boolean
  63.       If mciSendString("play MUSIC from 0 notify", "", 0, m_HWND) <> 0 Then
  64.             Restart = False
  65.             Exit Function
  66.       End If
  67.       
  68.       Restart = True
  69. End Function
  70.